import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;

import { IUserVo } from "../data/User";

@ccclass('PlayerCtrl')
export default class PlayerCtrl extends Component {
    
    @property(Label)
    idLable: Label = null

    @property(Label)
    nameLable: Label = null

    @property(Label)
    balanceLable: Label = null

    @property(Node)
    landImgNode: Node = null    // 地主图标，显示该用户是否是地主

    private _user: IUserVo
    private _isLand: boolean = false

    // onLoad() {

    // }

    public init(user: IUserVo) {
        this._user = user
        this.idLable.string = `ID: ${user.id}`
        this.nameLable.string = `${user.name}`
        this.balanceLable.string = `$: ${user.balance}`
        this._isLand = false
    }

    /**
     * 设置是否是地主
     */
    public setLand(value: boolean) {
        this._isLand = value
        if (this._isLand) {
            this.landImgNode.active = true
        } else {
            this.landImgNode.active = false
        }
    }

}


